#include <bits/stdc++.h>
using namespace std;

int t;
int n,m,L,V;
int d[100005],v[10005],a[10005];
int p[100005];
int ans1 = 0;
int ans2 = 0;
int minn = INT_MAX;

bool chk(int b,int c,int d){ // b = d[j],c = v[j],d = a[j];
	for(int i = 0;i < n;i ++){
		if(p[i] < b) continue;
		else{
			if(V < sqrt(c * c + 2 * d * (b - p[i]))) return true;
		}
	}
return false;
}
int f(int b,int c,int d){
	if(c < V) return n;
	else return 0;
}

int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin >> t;
	for(int i = 0;i < t;i ++){
		cin >> n >> m >> L >> V;
		for(int j = 0;j < n;j ++){
			cin >> d[j] >> v[j] >> a[j];
			
		}
		for(int j = 0;j < m;j ++){
			cin >> p[j];	
		}
		
		for(int j = 0;j < n;j ++){
			if(chk(d[j],v[j],a[j])) ans1 ++;
			minn = min(minn,f(d[j],v[j],a[j]));
		}
		
		cout << ans1 << ' ' << minn;
		cout << endl;
		ans1 = 0;
	}
	
return 0;	
}
